//
//  CNBestSellerTableViewCell.m
//  BeeQuick_19
//
//  Created by tanky on 2016/9/24.
//  Copyright © 2016年 CN Team. All rights reserved.
//

#import "CNBestSellerTableViewCell.h"
#import "CNBestSellerModel.h"
#import "CNGoodsDisplayView.h"

@interface CNBestSellerTableViewCell ()

@property(nonatomic,strong)CNGoodsDisplayView *firstView;
@property(nonatomic,strong)CNGoodsDisplayView *secondView;

@end

@implementation CNBestSellerTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    [self setupUI];
    return self;
}

- (void)setupUI{
    CGFloat screenWidth =  [UIScreen mainScreen].bounds.size.width;
    CGFloat maxMargin = 8;
    CGFloat rowHeight = 294;
    
    /** 当赋值时 创建屎大颗View 并添加内部视图*/
    UIStackView *doubleView = [[UIStackView alloc] initWithFrame:CGRectMake(maxMargin, maxMargin, screenWidth - 2 * maxMargin, rowHeight - 2 * maxMargin)];
    doubleView.axis = UILayoutConstraintAxisHorizontal;
    doubleView.alignment = UIStackViewAlignmentFill;
    doubleView.spacing = 10;
    doubleView.distribution = UIStackViewDistributionFillEqually;
    CNGoodsDisplayView *firstView = [[CNGoodsDisplayView alloc] init];
    CNGoodsDisplayView *secondView = [[CNGoodsDisplayView alloc] init];
    [doubleView addArrangedSubview:firstView];
    [doubleView addArrangedSubview:secondView];
    self.firstView = firstView;
    self.secondView = secondView;
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:doubleView];

}

- (void)setDoubleBSModelData:(NSArray *)doubleBSModelData{
    if (_doubleBSModelData != doubleBSModelData) {
        _doubleBSModelData = doubleBSModelData;
    }
    self.firstView.model = doubleBSModelData.firstObject;
    self.secondView.model = doubleBSModelData.lastObject;
}

@end
